#pragma once

namespace host
{

    typedef unsigned char MacAddr[6];
    typedef unsigned char IPv4Addr[4];
    typedef unsigned char IPv6Addr[16];
    typedef unsigned char IRPID[8];

    enum
    {
        IPV4_TYPE    = 0x0800,
        IPV6_TYPE    = 0x86dd,
        TCP_PROTOCOL = 0x06,
        UDP_PROTOCOL = 0x11,
        RTP_VERSION  = 0x80,
    };

    enum
    {
        ETH_HEAD_SIZE  = 14,
        IPV4_HEAD_SIZE = 20,
        UDP_HEAD_SIZE = 8,
        RTP_HEAD_SIZE = 12,
    };

#pragma pack(1)
    struct RTPPacket
    {
        unsigned char  vpxcc;
        unsigned char  ptype;
        unsigned short sequence;
        unsigned int   timestamp;
        unsigned int   ssrc;
        unsigned char  payload[4096];
    };

    struct UDPPacket
    {
        unsigned short srcport;
        unsigned short dstport;
        unsigned short length;
        unsigned short checksum;
        union
        {
            unsigned char payload[4096];
            struct RTPPacket RTPPkt;
        };
    };

    struct TCPPacket
    {
        union
        {
            unsigned char payload[4096];
        };
    };

    struct IPv4Packet
    {
        unsigned char  versoin;
        unsigned char  dsf; //differentiated services field
        unsigned short length;
        unsigned short idtf;
        unsigned short fragment;
        unsigned char  ttl;
        unsigned char  protocal;
        unsigned short checksum;
        IPv4Addr       source;
        IPv4Addr       destina;
        union
        {
            unsigned char payload[4096];
            struct UDPPacket UDPPkt;
            struct TCPPacket TCPPkt;
        };
    };

    struct IPv6Packet
    {
        unsigned int   versoin : 4;
        unsigned int   traffic_class : 8; //differentiated services field
        unsigned int   flow_table : 20;
        unsigned short length;
        unsigned char  next_hdr;
        unsigned char  hop_limit;
        IPv6Addr       source;
        IPv6Addr       destina;
        union
        {
            unsigned char payload[4096];
            struct UDPPacket UDPPkt;
            struct TCPPacket TCPPkt;
        };
    };

    struct ETHPacket
    {
        MacAddr destination;
        MacAddr source;
        unsigned short type;
        union
        {
            unsigned char payload[4096];
            struct IPv4Packet IPv4Pkt;
            struct IPv6Packet IPv6Pkt;
        };
    };

    struct URBPacket
    {
        unsigned short  length;
        IRPID           irp_id;
        unsigned int    status;
        unsigned short  urb_func;
        unsigned char   irp_info;
        unsigned short  irp_busid;
        unsigned short  devaddr;
        unsigned char   endpoint;
        unsigned char   trans_type;
        unsigned int    data_length;
        unsigned int    start_frame;
        unsigned int    pakcet_number;
        unsigned int    error_count;
        union
        {
            unsigned char payload[4096];
        };
    };

#pragma pack()
};
